package com.pipi.sso.dao.manager.impl;

import com.pipi.sso.dao.support.PageResult;
import com.pipi.sso.dao.model.MenuDO;
import com.pipi.sso.dao.query.MenuQuery;
import com.pipi.sso.dao.mapper.ext.MenuExtMapper;
import com.pipi.sso.dao.manager.MenuManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Menu.
 */

@Component
public class MenuManagerImpl implements MenuManager{

    
    @Autowired
    protected MenuExtMapper menuExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(MenuQuery query){
        return menuExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(MenuQuery query){
        return menuExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(MenuDO record){
        return menuExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(MenuDO record){
        return menuExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<MenuDO> selectByQuery(MenuQuery query){
        return menuExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<MenuDO> selectByQueryWithPage(MenuQuery query) {
        PageResult<MenuDO> result = new PageResult<MenuDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public MenuDO selectByPrimaryKey(Long id){
        return menuExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( MenuDO record,  MenuQuery query){
        return menuExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( MenuDO record,  MenuQuery query){

        return menuExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(MenuDO record){
        return menuExtMapper.updateByPrimaryKeySelective(record);
    }
}